﻿@{
    ViewBag.Title = "fantian";
    Layout = "~/Views/Users/Index.cshtml";
}

<script src="~/Scripts/jquery-1.8.2.min.js"></script>
<link href="~/css/bootstrap.css" rel="stylesheet" />
<script src="~/js/bootstrap.min.js"></script>
<script src="~/js/jquery.min.js"></script>

<table class="table table-responsive">
    <tr>
        <td></td>
        <td><input id="txtid" type="text" hidden="hidden" value="@ViewBag.list.FlowersID"/></td>
    </tr>
    <tr>
        <td>花卉名称</td>
        <td><input id="txtname" type="text" readonly="readonly" value="@ViewBag.list.FlowersName" /></td>
    </tr>
    <tr>
        <td>库存</td>
        <td><input id="txtkucun" type="text" value="@ViewBag.list.FlowersStock" /></td>
    </tr>
    <tr>
        <td>进货单价</td>
        <td><input id="txtjinhuo" type="text" value="@ViewBag.list.PurchasePrice" /></td>
    </tr>
    <tr>
        <td>销售单价</td>
        <td><input id="txtxiaoshou" type="text" value="@ViewBag.list.Sales_unit_price "/></td>
    </tr>
    <tr>
        <td><input type='button' value='编辑' class='btn btn-success' onclick='bianji()' /></td>
        <td><input type='button' value='取消' class='btn btn-success' onclick='return location.href = "/Flowers/FlowersIndex"' /></td>
    </tr>
</table>
<script>
    //function show()
    //{
    //    $.ajax({
    //        type: "get",
    //        url: "/Flowers/fantian/",
    //        success: function (obj) {
    //            $("#txtname").val() = obj.FlowersName;
    //            $("#txtkucun").val() = obj.FlowersStock;
    //            $("#txtjinhuo").val() = obj.PurchasePrice;
    //            $("#txtxiaoshou").val() = obj.Sales_unit_price;
    //            $("#txtstate").val() = obj.FlowerState;
    //        }
    //    })
    //}


    function bianji()
    {
        $.ajax({
            type:"post",
            url: "/Flowers/bianji/",
            data: {FlowersID:$("#txtid").val(), FlowersName: $("#txtname").val(), FlowersStock: $("#txtkucun").val(), PurchasePrice: $("#txtjinhuo").val(), Sales_unit_price: $("#txtxiaoshou").val()},
            success:function (obj){
                if(obj>0)
                {
                    alert('编辑成功');
                    location.href="/Flowers/FlowersIndex";
                    return;
                }
                alert('编辑失败');
            }
        })
    }
</script>